//
//  BaseViewController.m
//  weibo
//
//  Created by hp on 16/4/22.
//  Copyright © 2016年 hp. All rights reserved.
//

#import "BaseViewController.h"
#import "VisitorView.h"
#import "OAuthViewController.h"
@interface BaseViewController ()

@end

@implementation BaseViewController

// 加载视图的时候根据用户是否登陆，判断加载哪个页面
- (void)loadView
{

    if ([[UserAccount sharedUserAccount] isLogined]) {
        [super loadView];
    } else {
        VisitorView *view = [[VisitorView alloc] init];
        self.view = view;
        //记录一下
        self.visitorView = view;
        
        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(registerBtnPressed:)];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"登陆" style:UIBarButtonItemStylePlain target:self action:@selector(loginBtnPressed:)];
    }
}

- (void)registerBtnPressed:(id)sender
{
    
}

- (void)loginBtnPressed:(id)sender
{
    OAuthViewController *authVC = [[OAuthViewController alloc] init];
    UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:authVC];
    [self presentViewController:navi animated:YES completion:nil];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
